<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>收派时间管理</title>
    <!-- 导入jquery核心类库 -->
    <script type="text/javascript" src="../../js/jquery-1.8.3.js"></script>
    <!-- 导入easyui类库 -->
    <link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../../js/easyui/ext/portal.css">
    <link rel="stylesheet" type="text/css" href="../../css/default.css">
    <script type="text/javascript" src="../../js/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../js/easyui/ext/jquery.portal.js"></script>
    <script type="text/javascript" src="../../js/easyui/ext/jquery.cookie.js"></script>
    <script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            // 先将body隐藏，再显示，不会出现页面刷新效果
            $("body").css({visibility: "visible"});

            // 收派时间管理信息表格
            $('#grid').datagrid({
                iconCls: 'icon-forward',
                fit: true,
                border: false,
                rownumbers: true,
                striped: true,
                pageList: [30, 50, 100],
                pagination: true,
                toolbar: toolbar,
                url: "../../take_time_pageQuery.action",
                idField: 'id',
                columns: columns
            });
            $("#save").click(function () {
                if ($("#addForm").form('validate')) {
                    $("#addForm").submit();
                    $("#addWindow").window('close');
                } else {
                    $.messager.alert('警告信息', '有非法输入项', 'warning');
                }
            });
            $("#searchBtn").click(function () {
                var params = $("#searchForm").serializeObject();
                $("#grid").datagrid('load',params);
                $("#searchWindow").window('close');
            });
        });

        $.fn.serializeObject = function() {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function() {
                if(o[this.name] !== undefined) {
                    if(!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        };

        //工具栏
        var toolbar = [{
            id: 'button-add',
            text: '增加',
            iconCls: 'icon-add',
            handler: function () {
                $("#addWindow").window('open');
            }
        }, {
            id: 'button-edit',
            text: '修改',
            iconCls: 'icon-edit',
            handler: function () {
                var rows = $("#grid").datagrid('getSelections');
                if (rows.length == 1) {
                    $("#addForm").form('load', rows[0]);
                    $("#addWindow").window('open');
                } else {
                    $.messager.alert('警告信息', '请选择一条数据', 'warning');
                }
            }
        }, {
            id: 'button-delete',
            text: '删除',
            iconCls: 'icon-cancel',
            handler: function () {
                var rows = $("#grid").datagrid('getSelections');
                var arrs = new Array();
                for(var i=0;i<rows.length;i++){
                   arrs.add(rows[i].status);
                }
                var ids = arrs.join(',');
                window.location.href="../../take_time_save.action?status='1'&ids="+ids;
            }
        },
            {
                id: 'button-search',
                text: '查询',
                iconCls: 'icon-search',
                handler: function () {
                  $("#searchWindow").window("open");
                }
            }];

        // 定义列
        var columns = [[{
            field: 'id',
            checkbox: true,
        }, {
            field: 'name',
            title: '时间名称',
            width: 120,
            align: 'center'
        }, {
            field: 'normalWorkTime',
            title: '平时上班时间',
            width: 120,
            align: 'center'
        }, {
            field: 'normalDutyTime',
            title: '平时休息时间',
            width: 120,
            align: 'center'
        }, {
            field: 'satWorkTime',
            title: '周六上班时间',
            width: 120,
            align: 'center'
        }, {
            field: 'satDutyTime',
            title: '周六休息时间',
            width: 120,
            align: 'center'
        }, {
            field: 'sunWorkTime',
            title: '周日上班时间',
            width: 120,
            align: 'center'
        }, {
            field: 'sunDutyTime',
            title: '周日休息时间',
            width: 120,
            align: 'center'
        }, {
            field: 'status',
            title: '状态',
            width: 120,
            align: 'center',
            formatter: function(value,row,index){
                if (row.state){
                    return "正常使用";
                } else {
                    return "已作废";
                }
            }
        }, {
            field: 'company',
            title: '所属单位',
            width: 120,
            align: 'center'
        }, {
            field: 'operator',
            title: '操作人',
            width: 120,
            align: 'center'
        }, {
            field: 'operatingTime',
            title: '操作时间',
            width: 120,
            align: 'center'
        }, {
            field: 'operatingCompany',
            title: '操作单位',
            width: 120,
            align: 'center'
        }]];
    </script>
</head>
<body class="easyui-layout" style="visibility:hidden;">
<div region="center" border="false">
    <table id="grid"></table>
</div>
<div class="easyui-window" title="区域添加修改" , id="addWindow" closed="true"
     collapsible='false' minimizable='false' maximizable='false'
     style="width: 680px;height:360px;top: 20px; left: 200px;overflow:hidden;">
    <div style="height:31px;overflow:hidden;" split="false" border="false">
        <div class="datagrid-toolbar">
            <a id="save" icon="icon-save" href="javascript:void(0)" class="easyui-linkbutton" plain="true">保存</a>
        </div>
    </div>
    <div region="center" border="false" split="false" style="overflow: auto; padding: 5px;">
        <form id="addForm" action="../../take_time_save.action" method="post">
            <table class="table-edit" width="80%" align="center">
                <tr class="title">
                    <td colspan="4">收派时间信息</td>
                </tr>
                <tr>
                    <td>时间名称</td>
                    <td><input type="text" name="name" class="easyui-validatebox"
                               required="true"/></td>
                    <td>平时上班时间</td>
                    <td><input type="text" name="normalWorkTime"
                               class="easyui-validatebox" required="true"/></td>
                </tr>
                <tr>
                    <td>平时休息时间</td>
                    <td><input type="text" name="normalDutyTime" class="easyui-validatebox"
                               required="true"/></td>

                    <td>周六上班时间</td>
                    <td><input type="text" name="satWorkTime"
                               class="easyui-validatebox" required="true"/></td>
                </tr>
                <tr>
                    <td>周六休息时间</td>
                    <td><input type="text" name="satDutyTime"
                               class="easyui-validatebox" required="true"/></td>

                    <td>周日上班时间</td>
                    <td><input type="text" name="sunWorkTime"
                               class="easyui-validatebox" required="true"/></td>
                </tr>
                <tr>
                    <td>周日休息时间</td>
                    <td><input type="text" name="sunDutyTime"
                               class="easyui-validatebox" required="true"/></td>

                    <td>所属单位</td>
                    <td><input type="text" name="company"
                               class="easyui-validatebox" required="true"/></td>
                </tr>
                <tr>
                    <td>操作时间</td>
                    <td><input type="text" name="operatingTime"
                               class="easyui-datetimebox" required="true"/></td>

                    <td>操作人</td>
                    <td><input type="text" name="operator"
                               class="easyui-validatebox" required="true"/></td>
                </tr>
                <tr>
                    <td>操作单位</td>
                    <td colspan="3"><input type="text" name="operatingCompany"
                                           class="easyui-validatebox" required="true" style="width: 405px"/></td>
                </tr>
            </table>
        </form>
    </div>
</div>
<!--查询窗口-->
<div class="easyui-window" title="查询收派时间窗口" closed="true" id="searchWindow" collapsible="false" minimizable="false"
     maximizable="false" style="width: 400px; top:40px;left:200px">
    <div style="overflow:auto;padding:5px;" border="false">
        <form id="searchForm">
            <table class="table-edit" width="80%" align="center">
                <tr class="title">
                    <td colspan="2">查询条件</td>
                </tr>
                <tr>
                    <td>时间名称</td>
                    <td>
                        <input type="text" name="name"/>
                    </td>
                </tr>
                <tr>
                    <td>所属单位</td>
                    <td>
                        <input type="text" name="company"/>
                    </td>
                </tr>
                <tr>
                    <td>操作人</td>
                    <td>
                        <input type="text" name="operator"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <a id="searchBtn" href="javascript:void(0)" class="easyui-linkbutton"
                           data-options="iconCls:'icon-search'">查询</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
</body>
</html>
